#include "timing.h"
#include "parse.h"


Timing * timing;
//---------------------------------------------------------------------------

Timing::Timing ()
{
	model = new Model ();
}
//---------------------------------------------------------------------------





//---------------------------------------------------------------------------

void Timing::MarkCriticalFF (double k)
{
	double maxAT, thresholdAT;
	
	//** reset flags **
	for (int i = 0; i < C->flipflopSize(); i++)
		C->getFlipflop(i)->isCriticalFF = false;
	
	
	//** get AT **
	maxAT = GetMaxAT ();
	thresholdAT = maxAT - (maxAT * k);
	
	cerr << "maxAT - thresholdAT : " << maxAT << " - " << thresholdAT << endl;
	
	
	//** mark critical gate **
	for (int i = 0; i < C->flipflopSize(); i++)
		if (C->getFlipflop(i)->AT > thresholdAT)
			C->getFlipflop(i)->isCriticalFF = true;
			
			
	for (int i = 0; i < C->flipflopSize(); i++)
		if (C->getFlipflop(i)->isCriticalFF)
			cerr << "critical FF : " << C->getFlipflop(i)->getIndex() << endl;
}
//---------------------------------------------------------------------------

void Timing::CountCriticalPathFF (double k)
{
	double maxAT, thresholdAT;
		
	
	//** get AT **
	maxAT = GetMaxAT ();
	thresholdAT = maxAT - (maxAT * k);
	
	cerr << "maxAT - thresholdAT : " << maxAT << " - " << thresholdAT << endl;
	
	//** get RAT **
	GetRATALL (thresholdAT);	
	
	
	
	//** reset flags **
	Node * nodeP;
	
	for (int i = 0; i < C->gateSize(); i++)
		C->getGate(i)->setVisited(false);
	
	for (int i = 0; i < C->inputSize(); i++)
		C->getInput(i)->setVisited(true);

	for (int i = 0; i < C->outputSize(); i++)
	{
		nodeP = C->getOutput(i);
		nodeP->setVisited(true);
		
		if (nodeP->getOutput(0)->inputSize() > 1)
			nodeP->getOutput(0)->getInput(1)->setVisited(true);
	}
	
	for (int i = 0; i < C->flipflopSize(); i++)
	{
		nodeP = C->getFlipflop(i);
		nodeP->setVisited(true);
		
		for (int j = 0; j < nodeP->inputSize(); j++)
			for (int k = 0; k < nodeP->getInput(j)->inputSize(); k++)
		 		nodeP->getInput(j)->getInput(k)->setVisited(true);

	}			
	
	
	//** get # of critical paths inside the fanout corn **
	nodeArray = new Node * [C->gateSize()*10 + 100000];		
	int cnt=0;
	for (int i = 0; i < C->flipflopSize(); i++)
	{
		nodeP = C->getFlipflop(i);
		nodeP->cPathCount = 0;
		
		for (int j = 0; j < nodeP->getOutput(0)->outputSize(); j++)
			if (nodeP->getOutput(0)->getOutput(j)->RATTmp < 0)
			{
				nodeP->cPathCount += GetCPathCount (nodeP->getOutput(0)->getOutput(j));
			}
		
		if (nodeP->cPathCount > 0){
			cerr << "FF " << nodeP->getIndex() << " cPathCount : " << nodeP->cPathCount << endl;
			cnt+=nodeP->cPathCount;
		}
	}
	cout<<"# of critical Paths:"<<cnt<<endl;
	delete [] nodeArray;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

double Timing::GetMaxAT ()
{
	Node * nodeP;
	nodeArray = new Node * [C->gateSize()];

	//** reset flags **
	for (int i = 0; i < C->gateSize(); i++)
	{
		nodeP = C->getGate(i);
		nodeP->setVisited(false);
		nodeP->AT = 0;
		nodeP->ATTmp = 0;
	}
	
	for (int i = 0; i < C->inputSize(); i++)
	{
		nodeP = C->getInput(i);
		nodeP->setVisited(true);
		nodeP->AT = 0;
		nodeP->ATTmp = 0;
	}

	for (int i = 0; i < C->outputSize(); i++)
	{
		nodeP = C->getOutput(i);
		nodeP->setVisited(true);
		nodeP->AT = 0;
		nodeP->ATTmp = 0;	
	}
	
	for (int i = 0; i < C->flipflopSize(); i++)
	{
		nodeP = C->getFlipflop(i);
		nodeP->setVisited(true);
		nodeP->AT = 0;
		nodeP->ATTmp = 0;
	}	
		
	
	//** calculate AT for output nodes **	
	for (int i = 0; i < C->outputSize(); i++)
	{
		if (C->getOutput(i)->getOutput(0)->inputSize() < 2)
			C->getOutput(i)->AT = 0;
		else
			C->getOutput(i)->AT = GetAT (C->getOutput(i)->getOutput(0)->getInput(1));
		
//		cerr << "output gate " << C->getOutput(i)->getIndex() << " : " << C->getOutput(i)->AT << endl;		
	}
		
	//** calculate AT for FF **	
	for (int i = 0; i < C->flipflopSize(); i++)
	{		
		if (C->getFlipflop(i)->getInput(1)->inputSize() < 1)
			C->getFlipflop(i)->AT = 0;
		else
			C->getFlipflop(i)->AT = GetAT (C->getFlipflop(i)->getInput(1)->getInput(0));
		
//		cerr << "FF gate " << C->getFlipflop(i)->getIndex() << " : " << C->getFlipflop(i)->AT << endl;		
	}
	
	
	//** get max AT **
	double maxAT = 0;
	for (int i = 0; i < C->outputSize(); i++)
		if (C->getOutput(i)->AT > maxAT)
			maxAT = C->getOutput(i)->AT;

	for (int i = 0; i < C->flipflopSize(); i++)
		if (C->getFlipflop(i)->AT > maxAT)
			maxAT = C->getFlipflop(i)->AT;
			
//	cerr << "max AT : " << maxAT << endl;

	delete [] nodeArray;
	return maxAT;
}
//---------------------------------------------------------------------------

double Timing::GetAT (Node * nodeTarget)
{
	if (nodeTarget->getVisited())
		return nodeTarget->ATTmp;
	
	bool isReady;
	Node * nodeP, * nodeQ;
	double delayTmp;
	Signature signature;
	
	nodeArray[0] = nodeTarget;
	nodeIndex = 1;
	
	while (nodeIndex != 0)
	{		
		nodeP = nodeArray[nodeIndex-1];
		isReady = true;
		
		for (int i = 0; i < nodeP->inputSize(); i++)
			if (nodeP->getInput(i)->inputSize() != 0)
			{
				nodeQ = nodeP->getInput(i)->getInput(0);
				
				if (!nodeQ->getVisited())
				{
					nodeArray[nodeIndex++] = nodeQ;
					isReady = false;
				}
			}
		
		
		if (isReady)
		{
			// calculate delay for each pin, and take the max one
			for (int i = 0; i < nodeP->inputSize(); i++)
			{
				if (nodeP->getInput(i)->inputSize() == 0)
				{
					signature = nodeP->signature();
					
					delayTmp = 
					   (model->GD[signature].PD[i].raising[0] + 
					    model->GD[signature].PD[i].falling[0])/2.0;										    
				}
				else
				{
					nodeQ = nodeP->getInput(i)->getInput(0);
					signature = nodeP->signature();
					delayTmp = 
					   nodeQ->ATTmp + 
					   (model->GD[signature].PD[i].raising[0] + 
					    model->GD[signature].PD[i].falling[0])/2.0;
				}
				    
				if (delayTmp > nodeP->ATTmp)
					nodeP->ATTmp = delayTmp;
			}
			
			// set flags
			nodeP->setVisited(true);
			nodeIndex -= 1;			
		}
	}
	
	return nodeTarget->ATTmp;
}
//---------------------------------------------------------------------------

void Timing::GetRATALL (double thresholdAT)
{
	Node * nodeP;
	double delayTmp;
	
	nodeArray = new Node * [C->gateSize()];

	//** reset flags **
	for (int i = 0; i < C->gateSize(); i++)
	{
		nodeP = C->getGate(i);
		nodeP->setVisited(false);
		nodeP->RATTmp = 1000;
	}
	
	for (int i = 0; i < C->inputSize(); i++)
	{
		nodeP = C->getInput(i);
		nodeP->setVisited(true);
		nodeP->RATTmp = 1000;
	}

	for (int i = 0; i < C->outputSize(); i++)
	{
		nodeP = C->getOutput(i);
		nodeP->setVisited(true);
		nodeP->RATTmp = thresholdAT;	
		
		if (nodeP->getOutput(0)->inputSize() > 1)
		{
			nodeP->getOutput(0)->getInput(1)->setVisited(true);
			nodeP->getOutput(0)->getInput(1)->RATTmp = thresholdAT;
		}
	}
	
	for (int i = 0; i < C->flipflopSize(); i++)
	{
		nodeP = C->getFlipflop(i);
		nodeP->setVisited(true);
		nodeP->RATTmp = 1000;
		
		for (int j = 0; j < nodeP->inputSize(); j++)
			for (int k = 0; k < nodeP->getInput(j)->inputSize(); k++)
			{
		 		nodeP->getInput(j)->getInput(k)->setVisited(true);
				nodeP->getInput(j)->getInput(k)->RATTmp = thresholdAT;
			}
	}		
	
	
	
	//** calculate RAT from PI nodes **	
	for (int i = 0; i < C->inputSize(); i++)
	{	
		nodeP = C->getInput(i);
		
		// get RAT for all the immediate fan-out gate for PI
		for (int j = 0; j < nodeP->getInput(0)->outputSize(); j++)
		{
			GetRAT (nodeP->getInput(0)->getOutput(j));
			delayTmp = GetRAT_CalculateDelay (nodeP->getInput(0), nodeP->getInput(0)->getOutput(j));
			
			if (delayTmp < nodeP->RATTmp)
				nodeP->RATTmp = delayTmp;
		}

//		cerr << "Input gate " << nodeP->getIndex() << " : " << nodeP->RATTmp << endl;	
	}	
	
	
	//** calculate RAT from FF **	
	for (int i = 0; i < C->flipflopSize(); i++)
	{
		nodeP = C->getFlipflop(i);
	
	  // get RAT for all the immediate fan-out gate for FF
	  for (int j = 0; j < nodeP->getOutput(0)->outputSize(); j++)
	  {
	  	GetRAT (nodeP->getOutput(0)->getOutput(j));
	  	delayTmp = GetRAT_CalculateDelay (nodeP->getOutput(0), nodeP->getOutput(0)->getOutput(j));
	  	
			if (delayTmp < nodeP->RATTmp)
				nodeP->RATTmp = delayTmp;	  	
	  }
		
//		cerr << "FF " << nodeP->getIndex() << " : " << nodeP->RATTmp << endl;	
	}	
	
	
//	//** calculate slack for each gate
//	for (int i = 0; i < C->gateSize(); i++)
//		C->getGate(i)->slack = C->getGate(i)->RATTmp - C->getGate(i)->ATTmp;	
//
//	for (int i = 0; i < C->flipflopSize(); i++)
//		C->getFlipflop(i)->slack = C->getFlipflop(i)->RATTmp - 0.0;	
//	
//	for (int i = 0; i < C->inputSize(); i++)
//		C->getInput(i)->slack = C->getInput(i)->RATTmp - 0.0;	
//
//	for (int i = 0; i < C->outputSize(); i++)
//		C->getOutput(i)->slack = 0;	
		
		
	delete [] nodeArray;	
}
//---------------------------------------------------------------------------

void Timing::GetRAT (Node * nodeTarget)
{
	if (nodeTarget->getVisited())
		return;
	
	bool isReady;
	Node * nodeP, * nodeQ;
	double delayTmp; 
	
	nodeArray[0] = nodeTarget;
	nodeIndex = 1;
	
	while (nodeIndex != 0)
	{		
		nodeP = nodeArray[nodeIndex-1];
		isReady = true;
		
		if (nodeP->outputSize() != 0)
			for (int i = 0; i < nodeP->getOutput(0)->outputSize(); i++)
			{
				nodeQ = nodeP->getOutput(0)->getOutput(i);
				
				if (!nodeQ->getVisited())
				{
					nodeArray[nodeIndex++] = nodeQ;
					isReady = false;
				}
			}
		
		
		if (isReady)
		{			
			// calculate RAT for each output, and take the min one
			for (int i = 0; i < nodeP->getOutput(0)->outputSize(); i++)
			{
//				cerr << i << " : " << nodeP->getOutput(0)->getOutput(i)->RATTmp << endl;
				nodeQ = nodeP->getOutput(0)->getOutput(i);
				delayTmp = GetRAT_CalculateDelay (nodeP->getOutput(0), nodeQ);
		
				if (delayTmp < nodeP->RATTmp)
					nodeP->RATTmp = delayTmp;
			}
			
//			cerr << "node " << nodeP->getIndex() << " : " << nodeP->RATTmp << endl;
			
			// set flags    
			nodeP->setVisited(true);
			nodeIndex -= 1;			
		}
	}	

}
//---------------------------------------------------------------------------

double Timing::GetRAT_CalculateDelay (Signal * signalP, Node * nodeQ)
{
	bool isPinMatched = false;  
	double delayTmp;
	Signature signature;  
	
	signature = nodeQ->signature ();  
	isPinMatched = false;
	
	for (int j = 0; j < nodeQ->inputSize(); j++)
		if (nodeQ->getInput(j) == signalP)
		{
			delayTmp = 
			   nodeQ->RATTmp - 
			   (model->GD[signature].PD[j].raising[0] + 
		      model->GD[signature].PD[j].falling[0])/2.0;						
			
			isPinMatched = true;
		}
	
	if (!isPinMatched)
	{
		cerr << "Error!! Can't find correspoding input pin!!" << endl;
		exit (1);
	}	
	
	return delayTmp;
}
//---------------------------------------------------------------------------

int Timing::GetCPathCount (Node * nodeTarget)
{
	int count = 0;	
	Node * nodeP, * nodeQ;
	double delay;
	
	nodeArray[0] = nodeTarget;
	int nodeHead = 0;
	int nodeTail = 1;
	
	while (nodeHead < nodeTail)
	{		
		nodeP = nodeArray[nodeHead];
//		cerr << nodeHead << " - " << nodeTail << " : " << nodeP->RATTmp  << " - " << nodeP->getVisited() << endl;
		
		if (!nodeP->getVisited())
		{
//			cerr << nodeP->getOutput(0)->outputSize() << endl;
			for (int i = 0; i < nodeP->getOutput(0)->outputSize(); i++)
			{
				nodeQ = nodeP->getOutput(0)->getOutput(i);
				delay = GetPinDelay(nodeP->getOutput(0), nodeQ);
				
				if (nodeQ->RATTmp - nodeP->ATTmp - delay < 0)
					nodeArray[nodeTail++] = nodeQ;
			}
			
			nodeHead += 1;
		}
		else
		{			
			count += 1;
			nodeHead += 1;			
		}
	}		
	
	return count;
}
//---------------------------------------------------------------------------

double Timing::GetPinDelay (Signal * signalP, Node * nodeQ)
{
	Signature signature;  
	
	signature = nodeQ->signature ();  
	
	for (int j = 0; j < nodeQ->inputSize(); j++)
		if (nodeQ->getInput(j) == signalP)
		{
			return (model->GD[signature].PD[j].raising[0] + model->GD[signature].PD[j].falling[0])/2.0;						
		}
	
	cerr << "Error!! Can't find correspoding input pin!!" << endl;
	exit (1);	
}
//---------------------------------------------------------------------------






//---------------------------------------------------------------------------

Model::Model ()
{
	// 0:INPUT
	GD[0].pinCount = 0;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[0].PD[i].raising[j] = 0;
			GD[0].PD[i].falling[j] = 0;
		}
	
	// 1:OUTPUT
	GD[0].pinCount = 0;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[0].PD[i].raising[j] = 0;
			GD[0].PD[i].falling[j] = 0;
		}

	// 2:NOT
	GD[2].pinCount = 1;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[2].PD[i].raising[j] = 0;
			GD[2].PD[i].falling[j] = 0;
		}	
	
	GD[2].PD[0].raising[0] = 3.5698e-11;
	GD[2].PD[0].raising[1] = -0.6483e-11;
	GD[2].PD[0].raising[2] = 0.1871e-11;
	GD[2].PD[0].raising[3] = -0.3657e-11;
	GD[2].PD[0].raising[4] = -0.0037e-11;

	GD[2].PD[0].falling[0] = 1.9630e-11;
	GD[2].PD[0].falling[1] = -0.3586e-11;
	GD[2].PD[0].falling[2] = 0.0596e-11;
	GD[2].PD[0].falling[3] = 0.0081e-11;
	GD[2].PD[0].falling[4] = 0.2218e-11;

	// 3:FLIPFLOP,
	GD[0].pinCount = 0;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[0].PD[i].raising[j] = 0;
			GD[0].PD[i].falling[j] = 0;
		}
	
		
	// 4:NAND2
	GD[4].pinCount = 2;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[4].PD[i].raising[j] = 0;
			GD[4].PD[i].falling[j] = 0;
		}	
	
	GD[4].PD[0].raising[0] = 4.4077e-11;
	GD[4].PD[0].raising[1] = -0.7965e-11;
	GD[4].PD[0].raising[2] = 0.2383e-11;
	GD[4].PD[0].raising[3] = -0.4673e-11;
	GD[4].PD[0].raising[4] = -0.0028e-11;
	
	GD[4].PD[1].raising[0] = 5.0616e-11;
	GD[4].PD[1].raising[1] = -0.8381e-11;
	GD[4].PD[1].raising[2] = 0.2808e-11;
	GD[4].PD[1].raising[3] = -0.5369e-11;
	GD[4].PD[1].raising[4] = -0.0905e-11;
	

	GD[4].PD[0].falling[0] = 2.7711e-11;
	GD[4].PD[0].falling[1] = -0.4935e-11;
	GD[4].PD[0].falling[2] = 0.0801e-11;
	GD[4].PD[0].falling[3] = 0.0080e-11;
	GD[4].PD[0].falling[4] = 0.3188e-11;

	GD[4].PD[1].falling[0] = 3.0755e-11;
	GD[4].PD[1].falling[1] = -0.5802e-11;
	GD[4].PD[1].falling[2] = 0.0899e-11;
	GD[4].PD[1].falling[3] = -0.0123e-11;
	GD[4].PD[1].falling[4] = 0.3739e-11;


	// 5:NAND3
	GD[5].pinCount = 3;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[5].PD[i].raising[j] = 0;
			GD[5].PD[i].falling[j] = 0;
		}	
		
	GD[5].PD[0].raising[0] = 5.1668e-11;
	GD[5].PD[0].raising[1] = -0.9424e-11;
	GD[5].PD[0].raising[2] = 0.2939e-11;
	GD[5].PD[0].raising[3] = -0.5719e-11;
	GD[5].PD[0].raising[4] = -0.0009e-11;	

	GD[5].PD[1].raising[0] = 6.0823e-11;
	GD[5].PD[1].raising[1] = -1.0383e-11;
	GD[5].PD[1].raising[2] = 0.3565e-11;
	GD[5].PD[1].raising[3] = -0.6965e-11;
	GD[5].PD[1].raising[4] = -0.0465e-11;
	
	GD[5].PD[2].raising[0] = 6.8465e-11;
	GD[5].PD[2].raising[1] = -1.1581e-11;
	GD[5].PD[2].raising[2] = 0.4287e-11;
	GD[5].PD[2].raising[3] = -0.8331e-11;
	GD[5].PD[2].raising[4] = -0.1064e-11;
	
	GD[5].PD[0].falling[0] = 3.3020e-11;
	GD[5].PD[0].falling[1] = -0.6203e-11;
	GD[5].PD[0].falling[2] = 0.0953e-11;
	GD[5].PD[0].falling[3] = 0.0089e-11;
	GD[5].PD[0].falling[4] = 0.3987e-11;
	
	GD[5].PD[1].falling[0] = 3.9392e-11;
	GD[5].PD[1].falling[1] = -0.8239e-11;
	GD[5].PD[1].falling[2] = 0.1162e-11;
	GD[5].PD[1].falling[3] = 0.0045e-11;
	GD[5].PD[1].falling[4] = 0.5381e-11;
	
	GD[5].PD[2].falling[0] = 4.2629e-11;
	GD[5].PD[2].falling[1] = -0.9677e-11;
	GD[5].PD[2].falling[2] = 0.1314e-11;
	GD[5].PD[2].falling[3] = 0.0037e-11;
	GD[5].PD[2].falling[4] = 0.5999e-11;


	// 6:NOR2
	GD[6].pinCount = 2;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[6].PD[i].raising[j] = 0;
			GD[6].PD[i].falling[j] = 0;
		}		
	
	GD[6].PD[0].raising[0] = 6.3429e-11;
	GD[6].PD[0].raising[1] = -1.3148e-11;
	GD[6].PD[0].raising[2] = 0.3530e-11;
	GD[6].PD[0].raising[3] = -0.8641e-11;
	GD[6].PD[0].raising[4] = 0.0011e-11;
	
	GD[6].PD[1].raising[0] = 7.2657e-11;
	GD[6].PD[1].raising[1] = -1.6288e-11;
	GD[6].PD[1].raising[2] = 0.3967e-11;
	GD[6].PD[1].raising[3] = -0.9663e-11;
	GD[6].PD[1].raising[4] = 0.0139e-11;

	GD[6].PD[0].falling[0] = 2.4602e-11;
	GD[6].PD[0].falling[1] = -0.4299e-11;
	GD[6].PD[0].falling[2] = 0.0699e-11;
	GD[6].PD[0].falling[3] = 0.0093e-11;
	GD[6].PD[0].falling[4] =  0.2483e-11;
	
	GD[6].PD[1].falling[0] = 2.7686e-11;
	GD[6].PD[1].falling[1] = -0.4227e-11;
	GD[6].PD[1].falling[2] = 0.0788e-11;
	GD[6].PD[1].falling[3] = 0.0308e-11;
	GD[6].PD[1].falling[4] =  0.3017e-11;	


	// 7:NOR3
	GD[7].pinCount = 3;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[7].PD[i].raising[j] = 0;
			GD[7].PD[i].falling[j] = 0;
		}			

	GD[7].PD[0].raising[0] = 8.8468e-11;
	GD[7].PD[0].raising[1] = -2.0291e-11;
	GD[7].PD[0].raising[2] = 0.4985e-11;
	GD[7].PD[0].raising[3] = -1.3831e-11;
	GD[7].PD[0].raising[4] = 0.0093e-11;

	GD[7].PD[1].raising[0] = 11.1626e-11;
	GD[7].PD[1].raising[1] = -2.7080e-11;
	GD[7].PD[1].raising[2] = 0.5857e-11;
	GD[7].PD[1].raising[3] = -1.5807e-11;
	GD[7].PD[1].raising[4] = 0.0201e-11;
	
	GD[7].PD[2].raising[0] = 12.0131e-11;
	GD[7].PD[2].raising[1] = -2.9655e-11;
	GD[7].PD[2].raising[2] = 0.6337e-11;
	GD[7].PD[2].raising[3] = -1.7115e-11;
	GD[7].PD[2].raising[4] = 0.0245e-11;

	GD[7].PD[0].falling[0] = 2.9529e-11;
	GD[7].PD[0].falling[1] = -0.5001e-11;
	GD[7].PD[0].falling[2] = 0.0793e-11;
	GD[7].PD[0].falling[3] = 0.0116e-11;
	GD[7].PD[0].falling[4] = 0.2808e-11;
	
	GD[7].PD[1].falling[0] = 3.3476e-11;
	GD[7].PD[1].falling[1] = -0.4990e-11;
	GD[7].PD[1].falling[2] = 0.0897e-11;
	GD[7].PD[1].falling[3] = 0.0395e-11;
	GD[7].PD[1].falling[4] = 0.3292e-11;
	
	GD[7].PD[2].falling[0] = 3.5659e-11;
	GD[7].PD[2].falling[1] = -0.4739e-11;
	GD[7].PD[2].falling[2] = 0.0908e-11;
	GD[7].PD[2].falling[3] = 0.0677e-11;
	GD[7].PD[2].falling[4] = 0.3731e-11;

	
	// 8:UNDEFINED	
	GD[0].pinCount = 0;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 5; j++)
		{
			GD[0].PD[i].raising[j] = 0;
			GD[0].PD[i].falling[j] = 0;
		}
}
//---------------------------------------------------------------------------


